package com.xbh.cron4j;

import com.jfinal.plugin.redis.Redis;
import com.jfinal.token.ITokenCache;
import com.xbh.cache.MyTokenCache;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Set;
import java.util.function.Consumer;

/**
 * @MyRunnableImpl:
 * @description:
 * @author: ZBoHang
 * @time: 2021/7/26 16:26
 */
public class MyRunnableImpl implements Runnable {

    @Override
    public void run() {

        Set<String> tokenCacheSet = Redis.use("tokenCache").keys("*");
        if (tokenCacheSet.size() > 0) {
            tokenCacheSet.forEach(s -> Redis.use("tokenCache").del(s));
        }
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
        System.out.println("现在时刻<版本二>-->北京时间==" + LocalDateTime.now().format(dateTimeFormatter) + "已清理了Redis中所有token的缓存!");
    }
}
